/*
 * Created: 2022-08-25 19:21:47
 * Author : 涛涛涛
 */

import React, { useContext } from 'react';
import { View, Text, Image } from '@tarojs/components';
import { styled } from 'linaria/react';
import { useClassName } from '@/utils/index';
import { ProductItemContext } from '@/pages/Home/ProductList/ProductItem/ProductItemContext';

export interface IProps extends ICompProps {}
Avatar.defaultProps = {} as Partial<IProps>;
function Avatar(props: IProps) {
    const { className, style } = props;
    const localClassName = useClassName('Avatar', className);
    const {
        author: { avatarUrl },
    } = useContext(ProductItemContext);
    return (
        <RootView className={localClassName} style={style}>
            <Image className="img" src={avatarUrl}></Image>
        </RootView>
    );
}
export default React.memo(Avatar);
const RootView = styled(View)`
    &.Avatar {
        width: 60px;
        height: 60px;
        border-radius: 50%;
        overflow: hidden;
        .img {
            display: block;
            width: inherit;
            height: inherit;
        }
    }
`;
